package masterjava.common.ws;

import com.sun.xml.ws.developer.ValidationErrorHandler;
import org.apache.log4j.Logger;
import org.xml.sax.SAXException;
import org.xml.sax.SAXParseException;


public class ValidationHandler extends ValidationErrorHandler {
    private static MasterLogger LOGGER = Logger.get(ValidationHandler.class);
    public static final String MSG_INVALID_PARAMETERS = "Parameters mismatch the scheme: ";

    @Override
    public void warning(SAXParseException exception) throws SAXException {
        LOGGER.warn("Request validation warning: " + exception.toString(), exception);
    }

    @Override
    public void error(SAXParseException exception) throws SAXException {
        throw new IllegalArgumentException(MSG_INVALID_PARAMETERS + exception.getMessage(), exception);
    }

    @Override
    public void fatalError(SAXParseException exception) throws SAXException {
        throw new IllegalArgumentException(MSG_INVALID_PARAMETERS + exception.getMessage(), exception);
    }
}
